<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title>烧烤大亨 1.1公测版</title>
    <style>
        * {
            box-sizing: border-box;
            margin: 0;
            padding: 0;
            font-family: 'Microsoft YaHei', sans-serif;
            -webkit-tap-highlight-color: transparent;
        }
        body {
            background-color: #f5e6ca;
            color: #5c3d1e;
            line-height: 1.6;
            padding: 10px;
            background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><rect width="100" height="100" fill="%23f5e6ca"/><path d="M0,0 L100,100 M100,0 L0,100" stroke="%23e8d4b0" stroke-width="1"/></svg>');
            touch-action: manipulation;
        }
        .container {
            max-width: 100%;
            margin: 0 auto;
            background-color: #fff9e6;
            border-radius: 15px;
            box-shadow: 0 5px 15px rgba(0,0,0,0.1);
            padding: 15px;
            border: 3px solid #d4a55e;
        }
        header {
            text-align: center;
            margin-bottom: 15px;
            padding-bottom: 10px;
            border-bottom: 2px dashed #d4a55e;
        }
        h1 {
            color: #8b4513;
            font-size: 1.8em;
            margin-bottom: 8px;
            text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
        }
        .game-info {
            display: flex;
            justify-content: space-around;
            background-color: #f0d9b5;
            padding: 8px;
            border-radius: 10px;
            margin-bottom: 15px;
            flex-wrap: wrap;
        }
        .info-item {
            text-align: center;
            margin: 3px 5px;
            min-width: 70px;
        }
        .info-value {
            font-weight: bold;
            font-size: 1.1em;
            color: #8b4513;
        }
        .game-area {
            display: flex;
            flex-direction: column;
            gap: 15px;
            margin-bottom: 15px;
        }
        .action-panel, .status-panel, .cooking-panel {
            background-color: #f8f1e5;
            padding: 12px;
            border-radius: 10px;
            border: 2px solid #d4a55e;
        }
        h2 {
            color: #8b4513;
            margin-bottom: 12px;
            font-size: 1.3em;
            border-bottom: 1px solid #d4a55e;
            padding-bottom: 5px;
        }
        button {
            background-color: #d4a55e;
            color: #5c3d1e;
            border: none;
            padding: 12px 10px;
            margin: 5px 0;
            border-radius: 8px;
            cursor: pointer;
            font-weight: bold;
            transition: all 0.3s;
            width: 100%;
            font-size: 1em;
            min-height: 44px;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
        }
        button:hover, button:active {
            background-color: #c1954a;
            transform: translateY(-2px);
        }
        button:disabled {
            background-color: #cccccc;
            cursor: not-allowed;
            transform: none;
        }
        .event-log {
            background-color: #f0d9b5;
            padding: 12px;
            border-radius: 10px;
            height: 200px;
            overflow-y: auto;
            margin-top: 15px;
            border: 2px solid #d4a55e;
        }
        .log-entry {
            margin-bottom: 8px;
            padding-bottom: 8px;
            border-bottom: 1px dashed #d4a55e;
            font-size: 0.9em;
        }
        .log-time {
            font-size: 0.75em;
            color: #8b4513;
        }
        .upgrade-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 10px;
            padding: 8px;
            background-color: #f8f1e5;
            border-radius: 5px;
        }
        .upgrade-info {
            flex-grow: 1;
            font-size: 0.9em;
        }
        .resources {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 8px;
            margin-bottom: 12px;
        }
        .resource {
            background-color: #f0d9b5;
            padding: 8px;
            border-radius: 5px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            font-size: 0.9em;
        }
        .customer-info {
            background-color: #f0d9b5;
            padding: 10px;
            border-radius: 5px;
            margin-bottom: 10px;
        }
        .patience-bar {
            height: 10px;
            background-color: #e8d4b0;
            border-radius: 5px;
            margin: 5px 0;
            overflow: hidden;
        }
        .patience {
            height: 100%;
            background-color: #d4a55e;
            width: 100%;
            transition: width 0.5s;
        }
        .cooking-steps {
            margin: 10px 0;
        }
        .cooking-step {
            margin: 5px 0;
            padding: 5px;
            background-color: #f0d9b5;
            border-radius: 5px;
        }
        .step-active {
            background-color: #d4a55e;
            color: white;
            font-weight: bold;
        }
        
        /* 平板和桌面端适配 */
        @media (min-width: 768px) {
            .container {
                max-width: 750px;
                padding: 20px;
            }
            .game-area {
                display: grid;
                grid-template-columns: 1fr 1fr;
                gap: 20px;
            }
            .cooking-panel {
                grid-column: 1 / -1;
            }
            .resources {
                grid-template-columns: 1fr 1fr 1fr 1fr;
            }
            h1 {
                font-size: 2.2em;
            }
        }
        
        /* 大屏幕适配 */
        @media (min-width: 1024px) {
            .container {
                max-width: 900px;
            }
        }
        
        /* 防止文字过小 */
        @media (max-width: 360px) {
            button {
                font-size: 0.9em;
                padding: 10px 8px;
            }
            .info-item {
                min-width: 60px;
            }
        }
        
        /* 移动设备优化 */
        @media (hover: none) and (pointer: coarse) {
            button {
                transition: none;
            }
            button:active {
                transform: scale(0.95);
            }
        }
    </style>
</head>
<body>
    <div class="container">
        <header>
            <h1>🔥 烧烤大亨 1.1公测版 🔥</h1>
            <p>经营你的烧烤店，体验真实的烤串制作过程！</p>
        </header>
        
        <div class="game-info">
            <div class="info-item">
                <div>天数</div>
                <div class="info-value" id="day">1</div>
            </div>
            <div class="info-item">
                <div>资金</div>
                <div class="info-value" id="money">1000</div>
            </div>
            <div class="info-item">
                <div>声誉</div>
                <div class="info-value" id="reputation">50</div>
            </div>
            <div class="info-item">
                <div>满意度</div>
                <div class="info-value" id="satisfaction">80%</div>
            </div>
        </div>
        
        <div class="game-area">
            <div class="action-panel">
                <h2>店铺管理</h2>
                <div class="resources">
                    <div class="resource">肉类: <span id="meat">50</span></div>
                    <div class="resource">蔬菜: <span id="vegetable">30</span></div>
                    <div class="resource">调料: <span id="seasoning">40</span></div>
                    <div class="resource">炭火: <span id="charcoal">60</span></div>
                </div>
                
                <button id="buyMeat">购买肉类 ($50/10份)</button>
                <button id="buyVegetable">购买蔬菜 ($30/10份)</button>
                <button id="buySeasoning">购买调料 ($20/10份)</button>
                <button id="buyCharcoal">购买炭火 ($40/10份)</button>
                
                <h2>经营活动</h2>
                <button id="openShop">开始营业</button>
                <button id="upgradeShop">升级店铺 ($500)</button>
                <button id="advertise">广告宣传 ($200)</button>
                <button id="nextDay">结束今天</button>
            </div>
            
            <div class="status-panel">
                <h2>店铺状态</h2>
                <div>店铺等级: <span id="shopLevel">1</span></div>
                <div>员工数量: <span id="staffCount">1</span></div>
                <div>今日顾客: <span id="todayCustomers">0</span>/<span id="maxCustomers">5</span></div>
                <div>今日收入: $<span id="todayIncome">0</span></div>
                
                <h2>升级选项</h2>
                <div class="upgrade-item">
                    <div class="upgrade-info">
                        <div>烤架升级</div>
                        <div>提高烧烤效率</div>
                    </div>
                    <button class="upgrade-btn" data-upgrade="grill">$300</button>
                </div>
                <div class="upgrade-item">
                    <div class="upgrade-info">
                        <div>雇佣员工</div>
                        <div>增加同时服务的顾客</div>
                    </div>
                    <button class="upgrade-btn" data-upgrade="staff">$400</button>
                </div>
                <div class="upgrade-item">
                    <div class="upgrade-info">
                        <div>店铺装修</div>
                        <div>提高满意度和声誉</div>
                    </div>
                    <button class="upgrade-btn" data-upgrade="decor">$600</button>
                </div>
            </div>
            
            <div class="cooking-panel">
                <h2>顾客服务</h2>
                <div id="customerInfo" class="customer-info" style="display: none;">
                    <div>当前顾客: <span id="customerName">顾客</span></div>
                    <div>订单: <span id="customerOrder">烤串</span></div>
                    <div>耐心值: 
                        <div class="patience-bar">
                            <div id="customerPatience" class="patience" style="width: 100%;"></div>
                        </div>
                    </div>
                </div>
                
                <div id="cookingArea" style="display: none;">
                    <h3>烤串制作</h3>
                    <div class="cooking-steps">
                        <div id="step1" class="cooking-step">1. 准备食材</div>
                        <div id="step2" class="cooking-step">2. 串制烤串</div>
                        <div id="step3" class="cooking-step">3. 点火预热</div>
                        <div id="step4" class="cooking-step">4. 烤制食物</div>
                        <div id="step5" class="cooking-step">5. 添加调料</div>
                        <div id="step6" class="cooking-step">6. 装盘上菜</div>
                    </div>
                    <button id="nextStep">下一步</button>
                    <button id="serveCustomer" style="display: none;">服务顾客</button>
                </div>
                
                <div id="waitingArea">
                    <p>店铺尚未营业，点击"开始营业"接待顾客。</p>
                </div>
            </div>
        </div>
        
        <div class="event-log">
            <h2>游戏日志</h2>
            <div id="logContainer"></div>
        </div>
    </div>

    <script>
        // 检测移动设备
        function isMobileDevice() {
            return (('ontouchstart' in window) ||
                (navigator.maxTouchPoints > 0) ||
                (navigator.msMaxTouchPoints > 0));
        }
        
        // 游戏状态
        const gameState = {
            day: 1,
            money: 1000,
            reputation: 50,
            satisfaction: 80,
            isOpen: false,
            shopLevel: 1,
            staffCount: 1,
            maxCustomers: 5,
            todayCustomers: 0,
            todayIncome: 0,
            currentCustomer: null,
            cookingStep: 0,
            customerPatience: 100,
            patienceDecreaseInterval: null,
            
            // 资源
            resources: {
                meat: 50,
                vegetable: 30,
                seasoning: 40,
                charcoal: 60
            },
            
            // 升级状态
            upgrades: {
                grill: 1,
                staff: 1,
                decor: 1
            },
            
            // 价格设置
            prices: {
                meatSkewer: 15,
                vegSkewer: 10,
                combo: 25
            },
            
            // 事件日志
            log: [],
            
            // 顾客名字库
            customerNames: ["张三", "李四", "王五", "赵六", "钱七", "孙八", "周九", "吴十", "郑十一", "王十二"],
            
            // 订单类型
            orderTypes: [
                { name: "羊肉串", type: "meat", resourceCost: { meat: 2, seasoning: 1, charcoal: 2 } },
                { name: "牛肉串", type: "meat", resourceCost: { meat: 2, seasoning: 1, charcoal: 2 } },
                { name: "鸡翅", type: "meat", resourceCost: { meat: 3, seasoning: 1, charcoal: 3 } },
                { name: "烤韭菜", type: "vegetable", resourceCost: { vegetable: 2, seasoning: 1, charcoal: 1 } },
                { name: "烤茄子", type: "vegetable", resourceCost: { vegetable: 3, seasoning: 1, charcoal: 2 } },
                { name: "烤玉米", type: "vegetable", resourceCost: { vegetable: 2, seasoning: 1, charcoal: 2 } },
                { name: "豪华套餐", type: "combo", resourceCost: { meat: 3, vegetable: 2, seasoning: 2, charcoal: 4 } }
            ]
        };

        // DOM元素
        const elements = {
            day: document.getElementById('day'),
            money: document.getElementById('money'),
            reputation: document.getElementById('reputation'),
            satisfaction: document.getElementById('satisfaction'),
            meat: document.getElementById('meat'),
            vegetable: document.getElementById('vegetable'),
            seasoning: document.getElementById('seasoning'),
            charcoal: document.getElementById('charcoal'),
            shopLevel: document.getElementById('shopLevel'),
            staffCount: document.getElementById('staffCount'),
            todayCustomers: document.getElementById('todayCustomers'),
            maxCustomers: document.getElementById('maxCustomers'),
            todayIncome: document.getElementById('todayIncome'),
            logContainer: document.getElementById('logContainer'),
            customerInfo: document.getElementById('customerInfo'),
            customerName: document.getElementById('customerName'),
            customerOrder: document.getElementById('customerOrder'),
            customerPatience: document.getElementById('customerPatience'),
            cookingArea: document.getElementById('cookingArea'),
            waitingArea: document.getElementById('waitingArea'),
            nextStep: document.getElementById('nextStep'),
            serveCustomer: document.getElementById('serveCustomer'),
            
            // 按钮
            buyMeat: document.getElementById('buyMeat'),
            buyVegetable: document.getElementById('buyVegetable'),
            buySeasoning: document.getElementById('buySeasoning'),
            buyCharcoal: document.getElementById('buyCharcoal'),
            openShop: document.getElementById('openShop'),
            upgradeShop: document.getElementById('upgradeShop'),
            advertise: document.getElementById('advertise'),
            nextDay: document.getElementById('nextDay')
        };

        // 初始化游戏
        function initGame() {
            updateUI();
            addLog("欢迎来到烧烤大亨 1.1公测版！你的烧烤店今天开业了。");
            
            // 事件监听
            setupButtonEvents();
            
            // 如果是移动设备，优化触摸交互
            if (isMobileDevice()) {
                optimizeForMobile();
            }
        }

        // 设置按钮事件
        function setupButtonEvents() {
            elements.buyMeat.addEventListener('click', () => buyResource('meat', 50, 10));
            elements.buyVegetable.addEventListener('click', () => buyResource('vegetable', 30, 10));
            elements.buySeasoning.addEventListener('click', () => buyResource('seasoning', 20, 10));
            elements.buyCharcoal.addEventListener('click', () => buyResource('charcoal', 40, 10));
            
            elements.openShop.addEventListener('click', openShop);
            elements.upgradeShop.addEventListener('click', upgradeShop);
            elements.advertise.addEventListener('click', advertise);
            elements.nextDay.addEventListener('click', nextDay);
            
            elements.nextStep.addEventListener('click', nextCookingStep);
            elements.serveCustomer.addEventListener('click', serveCurrentCustomer);
            
            // 升级按钮
            document.querySelectorAll('.upgrade-btn').forEach(btn => {
                btn.addEventListener('click', function() {
                    const upgradeType = this.getAttribute('data-upgrade');
                    purchaseUpgrade(upgradeType);
                });
            });
        }

        // 为移动设备优化
        function optimizeForMobile() {
            // 移除可能导致双击的hover效果
            document.querySelectorAll('button').forEach(button => {
                button.style.transition = 'none';
            });
            
            // 使用touchstart事件替代click事件以获得更快响应
            document.querySelectorAll('button').forEach(button => {
                button.addEventListener('touchstart', function(e) {
                    // 防止默认行为以避免双击缩放
                    e.preventDefault();
                    
                    // 立即执行点击操作
                    this.click();
                    
                    // 添加视觉反馈
                    this.style.transform = 'scale(0.95)';
                    
                    // 短暂延迟后恢复原状
                    setTimeout(() => {
                        this.style.transform = '';
                    }, 150);
                }, {passive: false});
            });
            
            addLog("已检测到移动设备，优化触摸交互。");
        }

        // 更新UI
        function updateUI() {
            elements.day.textContent = gameState.day;
            elements.money.textContent = gameState.money;
            elements.reputation.textContent = gameState.reputation;
            elements.satisfaction.textContent = gameState.satisfaction + '%';
            
            elements.meat.textContent = gameState.resources.meat;
            elements.vegetable.textContent = gameState.resources.vegetable;
            elements.seasoning.textContent = gameState.resources.seasoning;
            elements.charcoal.textContent = gameState.resources.charcoal;
            
            elements.shopLevel.textContent = gameState.shopLevel;
            elements.staffCount.textContent = gameState.staffCount;
            elements.todayCustomers.textContent = gameState.todayCustomers;
            elements.maxCustomers.textContent = gameState.maxCustomers;
            elements.todayIncome.textContent = gameState.todayIncome;
            
            // 更新按钮状态
            elements.openShop.disabled = gameState.isOpen;
            elements.nextDay.disabled = !gameState.isOpen;
            
            // 检查资源是否充足
            elements.buyMeat.disabled = gameState.money < 50;
            elements.buyVegetable.disabled = gameState.money < 30;
            elements.buySeasoning.disabled = gameState.money < 20;
            elements.buyCharcoal.disabled = gameState.money < 40;
            elements.upgradeShop.disabled = gameState.money < 500;
            elements.advertise.disabled = gameState.money < 200;
            
            // 更新升级按钮
            document.querySelectorAll('.upgrade-btn').forEach(btn => {
                const upgradeType = btn.getAttribute('data-upgrade');
                let cost = 0;
                
                switch(upgradeType) {
                    case 'grill': cost = 300; break;
                    case 'staff': cost = 400; break;
                    case 'decor': cost = 600; break;
                }
                
                btn.disabled = gameState.money < cost;
                btn.textContent = `$${cost}`;
            });
        }

        // 添加日志
        function addLog(message) {
            const now = new Date();
            const timeString = `${now.getHours().toString().padStart(2, '0')}:${now.getMinutes().toString().padStart(2, '0')}`;
            
            gameState.log.unshift({
                time: timeString,
                message: message
            });
            
            // 限制日志数量
            if (gameState.log.length > 10) {
                gameState.log.pop();
            }
            
            // 更新日志显示
            elements.logContainer.innerHTML = '';
            gameState.log.forEach(entry => {
                const logEntry = document.createElement('div');
                logEntry.className = 'log-entry';
                logEntry.innerHTML = `<span class="log-time">[${entry.time}]</span> ${entry.message}`;
                elements.logContainer.appendChild(logEntry);
            });
        }

        // 购买资源
        function buyResource(type, cost, amount) {
            if (gameState.money >= cost) {
                gameState.money -= cost;
                gameState.resources[type] += amount;
                addLog(`购买了${amount}份${getResourceName(type)}，花费$${cost}。`);
                updateUI();
            } else {
                addLog("资金不足，无法购买资源。");
            }
        }

        // 获取资源名称
        function getResourceName(type) {
            switch(type) {
                case 'meat': return '肉类';
                case 'vegetable': return '蔬菜';
                case 'seasoning': return '调料';
                case 'charcoal': return '炭火';
                default: return '资源';
            }
        }

        // 开店营业
        function openShop() {
            if (gameState.isOpen) return;
            
            // 检查资源是否足够
            if (gameState.resources.meat < 5 || gameState.resources.vegetable < 3 || 
                gameState.resources.seasoning < 2 || gameState.resources.charcoal < 10) {
                addLog("资源不足，无法开业。请确保有足够的肉类、蔬菜、调料和炭火。");
                return;
            }
            
            gameState.isOpen = true;
            gameState.todayCustomers = 0;
            gameState.todayIncome = 0;
            
            addLog("店铺开始营业！等待顾客光临。");
            
            // 显示烹饪区域
            elements.waitingArea.style.display = 'none';
            elements.cookingArea.style.display = 'block';
            elements.customerInfo.style.display = 'block';
            
            updateUI();
            
            // 迎接第一位顾客
            welcomeNewCustomer();
        }

        // 迎接新顾客
        function welcomeNewCustomer() {
            if (!gameState.isOpen || gameState.todayCustomers >= gameState.maxCustomers) {
                addLog("今日营业结束，已服务所有顾客。");
                closeShop();
                return;
            }
            
            // 创建新顾客
            const customerName = gameState.customerNames[Math.floor(Math.random() * gameState.customerNames.length)];
            const order = gameState.orderTypes[Math.floor(Math.random() * gameState.orderTypes.length)];
            
            gameState.currentCustomer = {
                name: customerName,
                order: order,
                patience: 100,
                served: false
            };
            
            // 更新UI显示顾客信息
            elements.customerName.textContent = customerName;
            elements.customerOrder.textContent = order.name;
            updatePatienceBar(100);
            
            // 开始减少耐心值
            startPatienceDecrease();
            
            // 重置烹饪步骤
            resetCookingSteps();
            
            addLog(`${customerName}来到店里，点了${order.name}。`);
            
            gameState.todayCustomers++;
            updateUI();
        }

        // 开始减少耐心值
        function startPatienceDecrease() {
            if (gameState.patienceDecreaseInterval) {
                clearInterval(gameState.patienceDecreaseInterval);
            }
            
            gameState.patienceDecreaseInterval = setInterval(() => {
                if (gameState.currentCustomer && !gameState.currentCustomer.served) {
                    gameState.currentCustomer.patience -= 1;
                    updatePatienceBar(gameState.currentCustomer.patience);
                    
                    if (gameState.currentCustomer.patience <= 0) {
                        // 顾客失去耐心离开
                        addLog(`${gameState.currentCustomer.name}等得不耐烦，离开了店铺。满意度下降。`);
                        gameState.satisfaction = Math.max(0, gameState.satisfaction - 5);
                        updateUI();
                        welcomeNewCustomer();
                    } else if (gameState.currentCustomer.patience <= 30) {
                        // 顾客开始不耐烦
                        addLog(`${gameState.currentCustomer.name}开始显得不耐烦了。`);
                    }
                }
            }, 2000); // 每2秒减少1点耐心
        }

        // 更新耐心条
        function updatePatienceBar(patience) {
            elements.customerPatience.style.width = `${patience}%`;
            
            // 根据耐心值改变颜色
            if (patience > 70) {
                elements.customerPatience.style.backgroundColor = '#4caf50'; // 绿色
            } else if (patience > 30) {
                elements.customerPatience.style.backgroundColor = '#ff9800'; // 橙色
            } else {
                elements.customerPatience.style.backgroundColor = '#f44336'; // 红色
            }
        }

        // 重置烹饪步骤
        function resetCookingSteps() {
            gameState.cookingStep = 0;
            elements.nextStep.style.display = 'block';
            elements.serveCustomer.style.display = 'none';
            
            // 重置所有步骤的样式
            for (let i = 1; i <= 6; i++) {
                const stepElement = document.getElementById(`step${i}`);
                stepElement.className = 'cooking-step';
            }
        }

        // 下一步烹饪步骤
        function nextCookingStep() {
            if (gameState.cookingStep >= 6) return;
            
            // 标记当前步骤为完成
            const currentStepElement = document.getElementById(`step${gameState.cookingStep + 1}`);
            currentStepElement.classList.add('step-active');
            
            gameState.cookingStep++;
            
            // 如果是最后一步，显示服务按钮
            if (gameState.cookingStep === 6) {
                elements.nextStep.style.display = 'none';
                elements.serveCustomer.style.display = 'block';
                addLog(`烤串制作完成，准备为${gameState.currentCustomer.name}上菜。`);
            } else {
                addLog(`完成了第${gameState.cookingStep}步：${currentStepElement.textContent}`);
            }
        }

        // 服务当前顾客
        function serveCurrentCustomer() {
            if (!gameState.currentCustomer || gameState.currentCustomer.served) return;
            
            // 标记顾客已服务
            gameState.currentCustomer.served = true;
            
            // 停止耐心减少
            if (gameState.patienceDecreaseInterval) {
                clearInterval(gameState.patienceDecreaseInterval);
                gameState.patienceDecreaseInterval = null;
            }
            
            // 检查资源是否足够
            const order = gameState.currentCustomer.order;
            const resourceCost = order.resourceCost;
            let hasEnoughResources = true;
            
            for (const resource in resourceCost) {
                if (gameState.resources[resource] < resourceCost[resource]) {
                    hasEnoughResources = false;
                    break;
                }
            }
            
            if (!hasEnoughResources) {
                addLog("资源不足，无法完成订单。顾客失望地离开了。");
                gameState.satisfaction = Math.max(0, gameState.satisfaction - 10);
                updateUI();
                welcomeNewCustomer();
                return;
            }
            
            // 消耗资源
            for (const resource in resourceCost) {
                gameState.resources[resource] -= resourceCost[resource];
            }
            
            // 计算收入
            let baseIncome = 0;
            switch(order.type) {
                case 'meat': baseIncome = 20; break;
                case 'vegetable': baseIncome = 15; break;
                case 'combo': baseIncome = 30; break;
            }
            
            // 根据顾客耐心计算奖励/惩罚
            let patienceBonus = 0;
            if (gameState.currentCustomer.patience > 80) {
                patienceBonus = Math.floor(baseIncome * 0.2); // 高耐心奖励20%
                addLog(`${gameState.currentCustomer.name}非常满意，给了小费！`);
            } else if (gameState.currentCustomer.patience < 40) {
                patienceBonus = -Math.floor(baseIncome * 0.1); // 低耐心惩罚10%
                addLog(`${gameState.currentCustomer.name}对等待时间不满意，支付减少了。`);
            }
            
            const reputationBonus = Math.floor(gameState.reputation / 10);
            const randomBonus = Math.floor(Math.random() * 10);
            const income = baseIncome + patienceBonus + reputationBonus + randomBonus;
            
            gameState.todayIncome += income;
            gameState.money += income;
            
            // 更新满意度
            let satisfactionChange = Math.floor(Math.random() * 5) - 2;
            if (gameState.currentCustomer.patience > 70) {
                satisfactionChange += 2; // 高耐心增加满意度
            } else if (gameState.currentCustomer.patience < 30) {
                satisfactionChange -= 2; // 低耐心减少满意度
            }
            
            gameState.satisfaction = Math.max(0, Math.min(100, gameState.satisfaction + satisfactionChange));
            
            addLog(`为${gameState.currentCustomer.name}服务了${order.name}，收入$${income}。`);
            updateUI();
            
            // 迎接下一位顾客
            setTimeout(() => {
                welcomeNewCustomer();
            }, 1000);
        }

        // 关店
        function closeShop() {
            gameState.isOpen = false;
            
            // 停止耐心减少
            if (gameState.patienceDecreaseInterval) {
                clearInterval(gameState.patienceDecreaseInterval);
                gameState.patienceDecreaseInterval = null;
            }
            
            // 隐藏烹饪区域
            elements.cookingArea.style.display = 'none';
            elements.customerInfo.style.display = 'none';
            elements.waitingArea.style.display = 'block';
            
            updateUI();
            
            // 根据今日表现更新声誉
            if (gameState.todayCustomers > 0) {
                const reputationChange = Math.floor(gameState.todayCustomers / 2) + 
                                       Math.floor(gameState.satisfaction / 20);
                gameState.reputation += reputationChange;
                addLog(`今日营业结束，声誉提升了${reputationChange}点。`);
            }
        }

        // 升级店铺
        function upgradeShop() {
            if (gameState.money >= 500) {
                gameState.money -= 500;
                gameState.shopLevel++;
                gameState.maxCustomers += 2;
                addLog("店铺升级成功！现在可以服务更多顾客。");
                updateUI();
            } else {
                addLog("资金不足，无法升级店铺。");
            }
        }

        // 广告宣传
        function advertise() {
            if (gameState.money >= 200) {
                gameState.money -= 200;
                const reputationGain = 10 + Math.floor(Math.random() * 10);
                gameState.reputation += reputationGain;
                addLog(`广告宣传成功！声誉提升了${reputationGain}点。`);
                updateUI();
            } else {
                addLog("资金不足，无法进行广告宣传。");
            }
        }

        // 购买升级
        function purchaseUpgrade(type) {
            let cost = 0;
            let message = "";
            
            switch(type) {
                case 'grill':
                    cost = 300;
                    if (gameState.money >= cost) {
                        gameState.money -= cost;
                        gameState.upgrades.grill++;
                        message = "烤架升级完成，烧烤效率提高！";
                    }
                    break;
                case 'staff':
                    cost = 400;
                    if (gameState.money >= cost) {
                        gameState.money -= cost;
                        gameState.upgrades.staff++;
                        gameState.staffCount++;
                        message = "雇佣了新员工，服务能力提升！";
                    }
                    break;
                case 'decor':
                    cost = 600;
                    if (gameState.money >= cost) {
                        gameState.money -= cost;
                        gameState.upgrades.decor++;
                        gameState.satisfaction = Math.min(100, gameState.satisfaction + 10);
                        message = "店铺装修完成，顾客满意度提升！";
                    }
                    break;
            }
            
            if (message) {
                addLog(message);
                updateUI();
            } else {
                addLog("资金不足，无法购买此升级。");
            }
        }

        // 进入下一天
        function nextDay() {
            if (gameState.isOpen) {
                addLog("请先结束今天的营业，再进入下一天。");
                return;
            }
            
            gameState.day++;
            
            // 随机事件
            const eventChance = Math.random();
            if (eventChance < 0.3) {
                // 负面事件
                const events = [
                    { message: "今天天气不好，顾客减少。", effect: () => gameState.reputation -= 5 },
                    { message: "食材供应商涨价，成本增加。", effect: () => gameState.money -= 50 },
                    { message: "有顾客投诉，满意度下降。", effect: () => gameState.satisfaction -= 10 },
                    { message: "附近新开了一家烧烤店，竞争加剧。", effect: () => { gameState.reputation -= 3; gameState.satisfaction -= 5; } },
                    { message: "炭火质量不佳，烧烤效率降低。", effect: () => gameState.resources.charcoal -= 10 }
                ];
                const event = events[Math.floor(Math.random() * events.length)];
                event.effect();
                addLog(`事件：${event.message}`);
            } else if (eventChance < 0.6) {
                // 正面事件
                const events = [
                    { message: "今天是个好天气，顾客增多。", effect: () => gameState.reputation += 5 },
                    { message: "获得美食博主推荐，声誉大增。", effect: () => gameState.reputation += 15 },
                    { message: "食材供应商打折，节省了成本。", effect: () => gameState.money += 100 },
                    { message: "老顾客带来新朋友，生意兴隆。", effect: () => { gameState.reputation += 8; gameState.satisfaction += 5; } },
                    { message: "发现特价食材，库存增加。", effect: () => { 
                        gameState.resources.meat += 10; 
                        gameState.resources.vegetable += 10;
                    } }
                ];
                const event = events[Math.floor(Math.random() * events.length)];
                event.effect();
                addLog(`好消息：${event.message}`);
            }
            
            // 确保数值在合理范围内
            gameState.reputation = Math.max(0, gameState.reputation);
            gameState.satisfaction = Math.max(0, Math.min(100, gameState.satisfaction));
            
            addLog(`新的一天开始了！今天是第${gameState.day}天。`);
            updateUI();
        }

        // 启动游戏
        initGame();
    </script>
</body>
</html>
